home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 3: CDPD 3 / Almathera Ten on Ten - Disc 3: CDPD3.iso / ab20 / unarced / graphics / anim / unvscomp.asm < prev   
Assembly Source File  |  1995-03-17  |  5KB  |  168 lines

  1. ;
  2. ; This file is presented exactly as found in the file riffsrc.arc on the BIX
  3. ; listings area for the AMiga except for the addition of the README file 
  4. ; from the same arc file at the front end.  This was added to justify the
  5. ; PD nature of this code despite the existence of the copyright notice in
  6. ; the original file.
  7. ;
  8. ; *** README file ***
  9. ;
  10. ; Hello
  11. ;     here's the source code in Aztec C and assembler for Playriff. 
  12. ; It must be compiled with 32-bit-ints.  Though the code is PD and may
  13. ; be put to whatever use you see fit, I'm not giving away free consulting
  14. ; time to support it.  Nevertheless here's how to get in touch with me
  15. ; if you have some questions.
  16. ;    Jim Kent
  17. ;    Dancing Flame
  18. ;    739A 16th Ave.
  19. ;    San Francisco, CA 94118
  20. ;    or jim_kent on BIX.
  21. ;
  22. ; *** unvscomp.asm file ***
  23. ;
  24. ; unvscomp.asm  Copyright 1987 Dancing Flame all rights reserved.
  25. ;
  26. ; This file contains a single function which is set up to be called from
  27. ; C.  Ie the parameters are on the stack instead of registers.
  28. ;       decode_vkplane(in, out, linebytes)
  29. ; where in is a bit-plane's worth of vertical-byte-run-with-skips data
  30. ; and out is a bit-plane that STILL has the image from last frame on it.
  31. ; Linebytes is the number of bytes-per-line in the out bitplane, and it
  32. ; should certainly be noted that the external pointer variable ytable
  33. ; must be initialized to point to a multiplication table of
  34. ; 0*linebytes, 1*linebytes ... n*linebytes  before this routine is called.
  35. ; The format of "in":
  36. ;   Each column of the bitplane is compressed separately.  A 320x200
  37. ;   bitplane would have 40 columns of 200 bytes each.  The linebytes
  38. ;   parameter is used to count through the columns, it is not in the
  39. ;   "in" data, which is simply a concatenation of columns.
  40. ;
  41. ;   Each columns is an op-count followed by a number of ops.
  42. ;   If the op-count is zero, that's ok, it just means there's no change
  43. ;   in this column from the last frame.
  44. ;   The ops are of three classes, and followed by a varying amount of
  45. ;   data depending on which class.
  46. ;       1. Skip ops - this is a byte with the hi bit clear that says how many
  47. ;          rows to move the "dest" pointer forward, ie to skip. It is non-
  48. ;          zero
  49. ;       2. Uniq ops - this is a byte with the hi bit set.  The hi bit is
  50. ;          masked down and the remainder is a count of the number of bytes
  51. ;          of data to copy literally.  It's of course followed by the
  52. ;          data to copy.
  53. ;       3. Same ops - this is a 0 byte followed by a count byte, followed
  54. ;          by a byte value to repeat count times.
  55. ;   Do bear in mind that the data is compressed vertically rather than
  56. ;   horizontally, so to get to the next byte in the destination (out)
  57. ;   we add linebytes instead of one!
  58. ;
  59.  
  60.     public _decode_vkplane
  61.  
  62. firstp    set    16
  63. in    set    4+firstp
  64. out    set    8+firstp
  65. linebytes    set    14+firstp
  66.  
  67. _decode_vkplane
  68.     movem.l    a2/a3/d4/d5,-(sp)  ; save registers for Aztec C
  69.     move.l    in(sp),a0
  70.     move.l    out(sp),a2
  71.     move.w    linebytes(sp),d2
  72.     move.l    _ytable,a3
  73.     move.w    d2,d4    ; make a copy of linebytes to use as a counter
  74.     bra    zdcp    ; And go to the "columns" loop
  75.  
  76. dcp
  77.     move.l    a2,a1     ; get copy of dest pointer
  78.     clr.w    d0    ; clear hi byte of op_count
  79.     move.b    (a0)+,d0  ; fetch number of ops in this column
  80.     bra    zdcvclp   ; and branch to the "op" loop.
  81.  
  82. dcvclp    clr.w    d1    ; clear hi byte of op
  83.     move.b    (a0)+,d1    ; fetch next op
  84.     bmi    dcvskuniq ; if hi-bit set branch to "uniq" decoder
  85.     beq dcvsame    ; if it's zero branch to "same" decoder
  86.  
  87. skip            ; otherwise it's just a skip
  88.     add.w    d1,d1    ; use amount to skip as index into word-table
  89.     adda.w    0(a3,d1),a1
  90.     dbra    d0,dcvclp ; go back to top of op loop
  91.     bra    z1dcp     ; go back to column loop
  92.  
  93. dcvsame            ;here we decode a "vertical same run"
  94.     move.b    (a0)+,d1    ;fetch the count
  95.     move.b    (a0)+,d3  ; fetch the value to repeat
  96.     move.w    d1,d5     ; and do what it takes to fall into a "tower"
  97.     asr.w    #3,d5     ; d5 holds # of times to loop through tower
  98.     and.w    #7,d1     ; d1 is the remainder
  99.     add.w    d1,d1
  100.     add.w    d1,d1
  101.     neg.w    d1
  102.     jmp    34+same_tower(pc,d1) ; why 34?  8*size of tower
  103.                                          ;instruction pair, but the extra 2's
  104.                                          ;pure voodoo.
  105. same_tower
  106.     move.b    d3,(a1)
  107.     adda.w    d2,a1
  108.     move.b    d3,(a1)
  109.     adda.w    d2,a1
  110.     move.b    d3,(a1)
  111.     adda.w    d2,a1
  112.     move.b    d3,(a1)
  113.     adda.w    d2,a1
  114.     move.b    d3,(a1)
  115.     adda.w    d2,a1
  116.     move.b    d3,(a1)
  117.     adda.w    d2,a1
  118.     move.b    d3,(a1)
  119.     adda.w    d2,a1
  120.     move.b    d3,(a1)
  121.     adda.w    d2,a1
  122.     dbra    d5,same_tower
  123.     dbra    d0,dcvclp
  124.     bra    z1dcp
  125.  
  126. dcvskuniq                     ; here we decode a "unique" run
  127.     and.b    #$7f,d1   ; setting up a tower as above....
  128.     move.w    d1,d5
  129.     asr.w    #3,d5
  130.     and.w    #7,d1
  131.     add.w    d1,d1
  132.     add.w    d1,d1
  133.     neg.w    d1
  134.     jmp    34+uniq_tower(pc,d1)
  135. uniq_tower
  136.     move.b    (a0)+,(a1)
  137.     adda.w    d2,a1
  138.     move.b    (a0)+,(a1)
  139.     adda.w    d2,a1
  140.     move.b    (a0)+,(a1)
  141.     adda.w    d2,a1
  142.     move.b    (a0)+,(a1)
  143.     adda.w    d2,a1
  144.     move.b    (a0)+,(a1)
  145.     adda.w    d2,a1
  146.     move.b    (a0)+,(a1)
  147.     adda.w    d2,a1
  148.     move.b    (a0)+,(a1)
  149.     adda.w    d2,a1
  150.     move.b    (a0)+,(a1)
  151.     adda.w    d2,a1
  152.     dbra    d5,uniq_tower  ; branch back up to "op" loop
  153. zdcvclp dbra    d0,dcvclp      ; branch back up to "column loop"
  154.  
  155.     ; now we've finished decoding a single column
  156. z1dcp    addq.l    #1,a2  ; so move the dest pointer to next column
  157. zdcp    dbra    d4,dcp ; and go do it again what say?
  158.     movem.l    (sp)+,a2/a3/d4/d5
  159.     rts
  160.  
  161.     dseg
  162.     public _ytable ; saves me 8 cycles/op ... a lookup table
  163.                    ; on the y addresses.
  164.  
  165.  
  166.